/**
 * @author yusak
 */
ChaShaKu.StringsSearch = Ext.extend(Ext.app.Module,{
	id: "stringsSearch",
	run: function(){
		this.app.modules.searchMenuButtons.strings.setHandler(this.search,this);
	},
	search: function(o,e){
		var text = this.app.viewport.field.getValue();
		if(text){
			var target = this.app.viewport.mainPanel;
			var ds = Ext.app.Data.SentenceStore.create({url: 'optimized_search/sentences_by_strings'},{keywords:text});
			ds.on('beforeload',function(store,options){
				if(store.getTotalCount() > 0){
					options.params['total'] = store.getTotalCount();
				}
			});
			var p = target.add(Ext.app.Grid.KWICGrid.create(text,ds));
			target.setActiveTab(p);
			Ext.app.Grid.addAroundSearchMenu(p,target);
			ds.load({params:{start:0, limit:25}});
//			this.app.viewport.field.reset();
		}
	}
});
